WEBVTT

00:01.000 --> 00:02.830
Hello and welcome back to the costs.

00:02.890 --> 00:06.810
So at the end of the last session we created our first list.

00:07.360 --> 00:08.470
So what is the list.

00:08.470 --> 00:14.370
A list is another object or data type that stores multiple other objects.

00:14.380 --> 00:22.360
So for example a list can store objects of different data types like integer US floats drinks and so

00:22.360 --> 00:22.630
on.

00:24.520 --> 00:27.520
So let's stop creating our first or second list.

00:28.480 --> 00:32.020
So we are opening and square brackets and.

00:32.050 --> 00:32.370
Yeah.

00:32.380 --> 00:37.080
We are storing for entered into just one two three far separated by a comma.

00:37.900 --> 00:41.110
And then let's see what happens if you're on the cell.

00:41.590 --> 00:45.790
So it returns back to a list with four elements.

00:45.790 --> 00:47.470
One two three four.

00:47.590 --> 00:54.630
And if you check the type of El then we get back on that list.

00:54.860 --> 01:00.500
And as I said before we can store elements of different data types.

01:00.510 --> 01:08.920
So for example here we had the US now and our next list M we store three float elements.

01:09.590 --> 01:16.910
So let's execute here the cell and we can see here we have a list m with one point five two point four

01:16.940 --> 01:19.040
and three point seven.

01:19.040 --> 01:22.220
And also we can create a list with String objects.

01:22.250 --> 01:31.130
So for example list n uh we have a dock or we have a card and we have a mouse and we can have a list

01:31.160 --> 01:33.140
where we have different data types.

01:33.140 --> 01:41.810
So for example list o contains an integer one that contains a flow two point far and contains the string

01:41.810 --> 01:45.910
object dark and it's no problem at works.

01:46.700 --> 01:49.010
And you can think of a list like a backpack.

01:49.010 --> 01:54.740
So for example if you go hiking you put into your bag a bottle of water sandwich two T-shirts and maybe

01:54.740 --> 01:57.340
a football and a yard.

01:57.680 --> 02:03.560
Everything fits into your bag and that's the same as with the list so you can actually put everything

02:03.590 --> 02:09.110
into a list and store it there and we saw on the last session that we can transform a string into a

02:09.110 --> 02:10.100
list.

02:10.100 --> 02:12.250
So for example we have the string.

02:12.260 --> 02:21.110
This is a string and we can transform it by calling the function list and we get back a list with all

02:21.110 --> 02:22.700
single elements of the string.

02:22.700 --> 02:24.080
So T H I.

02:24.080 --> 02:26.450
Also an empty space.

02:26.450 --> 02:33.190
And also here at the exclamation mark so let's check again what data type we have here follower list

02:33.190 --> 02:40.610
P and of course it's a list and we can also count the amount of elements in the list.

02:42.190 --> 02:44.110
So in this case it's 17.

02:44.120 --> 02:46.330
And yeah we can have we can count here.

02:46.810 --> 02:54.940
And um yeah as we had before also the empty spaces and the exclamation marks also a string and also

02:54.940 --> 02:56.380
count four for the length.

02:56.860 --> 03:00.480
So next we can take the arithmetic sum of all elements.

03:00.490 --> 03:08.830
So we take the sum of l let's check L is on the list with four integers so a sum of four integers should

03:09.290 --> 03:10.030
should work.

03:10.990 --> 03:19.120
So the sum of one two three four four is ten and you can also take the sum of list m s so getting again

03:19.180 --> 03:24.880
m here is the list that's floating floats.

03:24.880 --> 03:26.380
So this should also work.

03:28.670 --> 03:30.520
So it's seven point six.

03:30.860 --> 03:38.410
And we tried to take the sum of lists and so list n and list and contains strings.

03:38.900 --> 03:40.530
So the sum of strings.

03:40.670 --> 03:42.080
I'm not sure if this works

03:45.430 --> 03:47.490
no it doesn't work so it gives less than Iran.

03:49.270 --> 03:54.620
So let's get back to lists L in list l there are four integers one two three four.

03:54.640 --> 04:03.100
And um what we can do with S and method Bill and method for lists called append and there we can append

04:03.580 --> 04:05.910
another element to the end of the list.

04:06.010 --> 04:11.110
So if we append five let's see what happens.

04:11.230 --> 04:15.940
So then we get back a list with a five in the end.

04:15.940 --> 04:21.040
And if you repeat this process and call a pen one more time with them the element five.

04:21.100 --> 04:22.730
So we get another five.

04:23.620 --> 04:24.110
And.

04:24.160 --> 04:28.750
There's also a method that counts the number of occurrences of one element.

04:28.750 --> 04:35.950
So if you want to count the number of occurrences of element five we can do so by calling the method

04:35.950 --> 04:38.690
count that we have to.

04:38.720 --> 04:46.730
So we have two times um the element five and now we can also remove an element from a list by calling

04:46.730 --> 04:52.140
the method remove and in brackets we have the element we want to remove.

04:52.170 --> 04:54.220
And so we have fear.

04:54.260 --> 05:01.970
We want to remove five and we have two times five on our list and the method remove removes the first

05:02.030 --> 05:04.380
occurrence of an element.

05:04.400 --> 05:05.060
Let's check.

05:05.910 --> 05:06.190
Okay.

05:06.230 --> 05:15.200
So now we have only only if the five only ones and we can account again the five and s so we have one

05:15.200 --> 05:22.580
time we have five on our list and we can also reverse the sequence of our elements by calling the method

05:22.700 --> 05:25.220
reverse.

05:25.220 --> 05:26.200
So let's do this.

05:26.210 --> 05:31.850
And now you can see so before our the sequence of our lists was one two three four five and now we are

05:31.850 --> 05:39.600
half and the reverse sequence five four three two one and that's also a method called Sarge where we

05:39.600 --> 05:41.630
can start our list.

05:41.730 --> 05:49.710
So in the case where we have only integers in our list Python automatically thoughts from from low to

05:49.710 --> 05:50.100
high.

05:50.760 --> 05:51.840
So let's see what happens

05:56.160 --> 06:01.740
and there's also the possibility to reverse the order with the method thought.

06:01.770 --> 06:07.860
So that's apparently the called reverse and it's uh by default it's set to fall.

06:07.890 --> 06:15.770
But we can set it to true and now we affirm the reverse order and we can sort it again

06:18.820 --> 06:21.310
to the ascending order.

06:21.370 --> 06:22.680
So beginning with one.

06:24.650 --> 06:25.410
All right.

06:27.270 --> 06:33.980
And what we can also do we can add a list and a list so we have a list containing one two three four

06:33.980 --> 06:34.640
five.

06:34.680 --> 06:40.000
And we can add another list containing three integers six seven and eight.

06:40.980 --> 06:45.800
So now we have a combined or a concatenated list.

06:45.810 --> 06:47.790
One two three four five six seven eight.

06:47.790 --> 06:49.080
So we have eight elements.

06:49.080 --> 06:50.260
No one list.

06:51.000 --> 06:54.490
And what is not working actually so we cannot subtract two.

06:54.540 --> 06:55.320
Two lists.

06:55.320 --> 07:00.450
So that s guess less an error message.

07:00.450 --> 07:02.730
All right so let's go back to our initial list.

07:02.760 --> 07:08.430
So we have a list with five elements and let's try to multiply our list.

07:08.450 --> 07:14.510
Um with two and let's see what we get.

07:14.580 --> 07:18.270
So actually Python here it concatenate many copies.

07:18.300 --> 07:22.080
So in this case two copies and um yeah.

07:22.080 --> 07:25.010
As you can see this is not an element y's multiplication.

07:25.020 --> 07:32.640
So if you see at the times two you could also expect that uh one is uh multiplied by two two is multiplied

07:32.640 --> 07:33.630
by two.

07:33.690 --> 07:37.350
So that in the end we get two four six eight ten.

07:37.350 --> 07:41.460
But this is not the case so this is not our how lists work.

07:41.460 --> 07:50.560
So we just get many copies of the same lists here and uh for the sake of completeness um division of

07:50.590 --> 07:51.580
uh lists.

07:51.740 --> 07:52.870
An into us.

07:52.930 --> 07:55.180
Uh not possible.

07:55.180 --> 07:55.540
All right.

07:55.540 --> 07:57.720
So that's uh that's it for.

07:57.730 --> 08:03.700
For the time being and uh hope to see you again and lists parts 2 or so C in the next session by.
